<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>

        ajax('../php/03reg.php' , function(data) {
            console.log(data);
        })


        function ajax(url, cb) {
            const xhr = new XMLHttpRequest();
            xhr.open('get', url, true);
            xhr.send();
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4 && xhr.status === 200) {
                    let data = xhr.responseText;
                    // console.log(data);
                    data = JSON.parse(data);
                    // console.log(data);

                    // 数据请求成功以后想处理数据   --- 想做一件事情 --- 函数
                    cb(data);

                }
            }
        }
    </script>

</body>

</html>